<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>动态绑定数据</title>
</head>
<body>
<div id="change" class="change">
    <img data-bind:src="imgUrl" alt=""/>
</div>
<script>
    let imgUrl = "https://www.cmse.gov.cn/xwzx/202511/W020251101161154105825.jpg"

    let element = document.querySelector("#change > img");

    let attributeNames = element.getAttributeNames();
    console.log(attributeNames);

    for (let i = 0; i < attributeNames.length; i++) {
        if (attributeNames[i] === "data-bind:src") {
            // 获取属性的值
            let attribute = element.getAttribute(attributeNames[i]);

            let strings = attributeNames[i].split(":");
            console.log(strings[strings.length - 1]);

            element.removeAttribute(attributeNames[i])
            element.setAttribute(strings[strings.length - 1], eval(attribute))
        }
    }


</script>
</body>
</html>